package com.youlu.campus.service.activity;

import com.youlu.campus.base.interactive.vo.ActivitySignUpRequest;
import com.youlu.campus.base.interactive.vo.ActivityVO;
import com.youlu.campus.common.base.QResult;
import com.youlu.campus.entity.ActivityFeedInfo;
import com.youlu.campus.entity.ActivityInfo;
import com.youlu.campus.entity.ActivityInfoVo;
import com.youlu.campus.entity.ActivityQaInfo;
import com.youlu.campus.entity.ActivityRewardRule;
import com.youlu.campus.entity.ActivityTaskInfo;
import com.youlu.campus.entity.UserInviteRecord;
import com.youlu.campus.entity.UserPO;
import com.youlu.campus.entity.UserParticipateActivityInfo;
import com.youlu.campus.entity.UserParticipateActivityTaskInfo;
import com.youlu.campus.entity.UserQaInfo;
import com.youlu.campus.entity.VO.RankingListQueryVO;
import com.youlu.campus.entity.VO.req.ActivityFeedQueryVO;
import com.youlu.campus.entity.VO.req.ActivityQaInfoVO;
import com.youlu.campus.entity.VO.req.RankingListResVO;
import com.youlu.campus.entity.VO.req.ReceiveCaVO;
import com.youlu.campus.entity.VO.req.UserDoQaVO;
import com.youlu.campus.entity.VO.req.UserInviteCreateVO;
import com.youlu.campus.entity.VO.req.UserInviteQueryVO;
import com.youlu.campus.entity.VO.req.UserParticipateActivityInfoQueryVO;
import com.youlu.campus.entity.VO.res.MultiQaRes;
import com.youlu.campus.entity.VO.res.PlatformActivityInfo;
import com.youlu.campus.entity.VO.res.QaTaskRes;
import com.youlu.campus.entity.VO.res.UserCaInfoRes;
import com.youlu.campus.entity.domain.ActivityFootPrintDomain;
import com.youlu.campus.entity.domain.ActivityRewadDomain;
import com.youlu.campus.entity.domain.ActivityTaskDataDomain;
import com.youlu.campus.entity.domain.PlayBillDomain;
import com.youlu.campus.entity.domain.ShareBindingDomain;
import com.youlu.campus.entity.domain.UserCaQueryDomain;
import com.youlu.campus.entity.domain.WechatH5PayConfigDomain;
import com.youlu.campus.entity.enums.TaskBizType;
import org.springframework.data.domain.Page;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;


public interface ActivityService {

    List<ActivityInfo> findAll();

    /**
     * 用户参与的活动列表
     *
     * @param req
     * @return
     */
    Page<ActivityInfo> myActivityList(UserParticipateActivityInfoQueryVO req);

    /**
     * 全部活动列表
     *
     * @return
     */
    Page<ActivityInfo> list(ActivityVO vo);

    /**
     * 全部活动列表
     *
     * @return
     */
    Page<ActivityInfoVo> findByPageAndUnfinished(ActivityVO vo);


    /**
     * 获取用户已参与活动列表
     *
     * @param request
     * @return
     */
     Page<ActivityInfoVo> findByPageAndJoined(ActivityVO request) ;

    /**
     * 首页活动列表
     *
     * @param platform
     * @return
     */
    List<PlatformActivityInfo> getPublicActivityInfo(String platform, String appId);

    Page<ActivityInfo> activityList(ActivityVO vo);

    /**
     * 匿名查看活动
     *
     * @param activityId
     * @return
     */
    UserParticipateActivityInfo anonymousQuery(UserPO userPO, String activityId);

    /**
     * 获取活动详情
     *
     * @param
     * @param id
     * @return
     */
    UserParticipateActivityInfo query(UserPO userPO, String id, Boolean no, String platform);

    /**
     * 获取活动信息
     *
     * @param id
     * @return
     */
    ActivityInfo findOne(String id);

    /**
     * 获取高校大赛排行榜 废弃
     *
     * @param req
     */
    @Deprecated
    RankingListResVO getUniversityContestRanking(RankingListQueryVO req, UserPO userPO);

    /**
     * 获取高校大赛排行榜 version2
     *
     * @param req
     */
    RankingListResVO getUniversityContestRanking2(RankingListQueryVO req, UserPO userPO);


    /**
     * 申请单位排行榜
     *
     * @param req
     */
    RankingListResVO getOrganizerRanking(RankingListQueryVO req, UserPO userPO);

    /**
     * 用户任务排行榜
     */
    RankingListResVO getUserTaskRanking(RankingListQueryVO req, UserPO userPO);


    /**
     * 排名:活动ID、时间、任务ID、用户ID
     */
    Integer getUserTaskRankingOrderNo(RankingListQueryVO req);

    /**
     * 用户邀请记录
     *
     * @param req
     * @return
     */
    Page<UserInviteRecord> getUserInviteRecord(UserInviteQueryVO req);

    /**
     * 创建活动邀请
     *
     * @param req
     * @return
     */
    boolean createActivityInvite(UserInviteCreateVO req);

    /**
     * 创建活动邀请
     *
     * @param req
     * @return
     */
    QResult createActivityInvite2(UserInviteCreateVO req);

    /**
     * 任务类型,0:志愿者邀请,1:大赛,2:邀请和大赛,3:打卡,4:打卡和邀请
     * 打卡为长期任务,只有一个激活
     */
    List<ActivityInfo> findByTaskType(Integer taskType, Boolean status);

    /**
     * 获取打卡默认的活动,全局只有一个打卡的活动
     *
     * @return
     */
    ActivityInfo findDailyAttendanceActivityInfo();

    /**
     * 获取活动任务
     *
     * @param activityId
     * @param taskBizType
     * @return
     */
    ActivityTaskInfo findActivityTaskInfo(String activityId, TaskBizType taskBizType);

    /**
     * 更新用户周榜单
     *
     * @param userPO
     * @param taskInfo
     * @param optType,0:累加,1:替换
     */
    void updateUserTaskWeekRanking(final UserPO userPO, UserParticipateActivityTaskInfo taskInfo,
                                   final Integer optType);

    /**
     * 查找活动任务
     *
     * @param id
     * @return
     */
    ActivityTaskInfo findActivityTaskInfo(String id);

    /**
     * 获取志愿时长
     *
     * @param userId
     * @return
     */
    Integer getVolunteerDuration(String userId);

    /**
     * 收藏/取消收藏活动
     *
     * @param userId
     * @param activityId
     * @param favorited
     * @return
     */
    boolean favoriteActivity(String userId, String activityId, Boolean favorited);

    /**
     * 获取活动问题
     */
    List<ActivityQaInfoVO> getQa(ActivityQaInfoVO req);


    ActivityQaInfo getQaInfo(ActivityQaInfoVO req);

    /**
     * 提交答题
     *
     * @param req
     * @return
     */
    UserParticipateActivityInfo doQa(UserDoQaVO req);

    /**
     * 获取奖励详情
     *
     * @param activityId
     * @param userId
     * @return
     */
    ActivityRewadDomain getReward(String activityId, String userId, String taskBizType);

    /**
     * 活动分享绑定
     *
     * @param req
     * @return
     */
    boolean shareBinding(ShareBindingDomain req);

    /**
     * 获取活动任务Feeds
     *
     * @param req
     * @return
     */
    Page<ActivityFeedInfo> getTaskFeeds(ActivityFeedQueryVO req);

    /**
     * 检查用户是否领取奖励
     *
     * @param activityId
     * @param userId
     * @return
     */
    boolean isGetReward(String activityId, String userId);

    WechatH5PayConfigDomain getPayConfig(UserPO userPO, String url, String nonce_str, String timestampStr);

    /**
     * 获取分享JS SDK配置
     *
     * @param userPO
     * @param url
     * @return
     */
    WechatH5PayConfigDomain getShareConfig(UserPO userPO, String url);

    /**
     * 获取分享JS SDK配置
     *
     * @param appId
     * @param url
     * @return
     */
    WechatH5PayConfigDomain getJsSdkConfigByAppId(String appId, String url);

    /**
     * 导出承办用户
     *
     * @param response
     * @returngetPayConfig
     */
    String exportOrgUsers(String userId, String activityId, HttpServletResponse response);

    /**
     * 导出所有用户
     *
     * @param response
     * @return
     */
    boolean orderAllUsers(HttpServletResponse response);


    /**
     * 用户证书查询接口
     *
     * @param mobile
     * @return
     */
    UserCaQueryDomain queryCa(String mobile, String activityId, String taskBizType);


    HashMap<String, Object> importUserCa(MultipartFile file, String activityId);

    /**
     * 获取线下活动详情
     *
     * @param activityId
     * @return
     */
    ActivityInfo getOffLineDetail(String activityId);

    /**
     * 获取任务详情
     **/

    ActivityTaskInfo getTaskInfo(String activityId, TaskBizType taskBizType);

    /**
     * 获取活动任务列表
     **/

    List<ActivityTaskInfo> getTaskList(String activityId);

    /**
     * 获取分享海报
     *
     * @param userPO
     * @param taskId
     * @return
     */
    PlayBillDomain getPlayBill(UserPO userPO, String taskId, String appId, String platform, String authMode);

    /**
     * 补偿有问题数据
     *
     * @param activityId
     * @return
     */
    boolean reeData(String activityId, UserPO userPO);

    /**
     * 证书领取
     *
     * @param activityId
     * @param userPO
     * @return
     */
    ReceiveCaVO receiveCa(String activityId, String appId, UserPO userPO, Integer rewardType);


    /**
     * 获取活动任务明细
     *
     * @param activityInfo
     * @param userId
     * @return
     */
    ActivityTaskDataDomain getActivityTaskDataDomain(ActivityInfo activityInfo, String userId);


    ActivityTaskDataDomain getActivityOrgTaskDomain(ActivityInfo activityInfo, String userId);

    /**
     * 获取用户证书信息
     *
     * @param activityId
     * @param taskBizType
     * @param userId
     * @return
     */
    UserCaInfoRes getUserCaInfo(String activityId, String taskBizType, String userId, String mobile, String openId);

    /**
     * 更新证书领取信息
     *
     * @param req
     * @return
     */
    boolean updateRecieveCaInfo(UserCaInfoRes req, String userId, String openId);
    /**
     * 获取证书信息
     */
    /**
     * 获取证书信息
     *
     * @param activityId
     * @param userId
     * @return
     */
    ActivityRewadDomain getPreCaInfo(String activityId, String userId, String openId, String taskBizType, String mobile);

    /**
     * 补偿省榜单数据
     *
     * @param activityId
     * @param taskId
     * @return
     */
    boolean reeDataProvince(String activityId, String taskId);

    /**
     * 获取用户报名信息
     *
     * @param userId
     * @param mobile
     * @return
     */
    ActivitySignUpRequest getActivitySignUpInfo(String userId, String mobile, String activityId, Integer type);

    /**
     * 获取答题任务
     *
     * @param activityId
     * @return
     */
    QaTaskRes queryQaTask(String activityId, Integer no, String userId);

    /**
     * queryQaTask
     * 查询任务详情
     *
     * @param activityId
     * @param taskBizType
     * @return
     */
    ActivityTaskInfo queryTask(String activityId, TaskBizType taskBizType);

    /**
     * 提交多级答题
     *
     * @param req
     * @return
     */
    MultiQaRes doMultiQa(UserDoQaVO req);

    /**
     * 获取活动数据
     *
     * @param activityId
     * @return
     */
    ActivityInfo getActivityInfo(String activityId);

    /**
     * 签到更新用户榜单
     *
     * @param userPO
     * @param activityId
     */
    void updateRank(UserPO userPO, String activityId, Double ratio);

    /**
     * 获取报名信息
     *
     * @param userId
     * @param activityId
     * @return
     */
    UserParticipateActivityInfo getUserParticipateActivityInfo(String userId, String activityId);

    /**
     * 获取用户答题记录
     *
     * @param userId
     * @param activityId
     * @return
     */
    UserQaInfo getUserQa(String userId, String activityId);

    /**
     * 导出全部用户信息
     *
     * @param optName
     * @param userId
     * @param response
     * @return
     */
    String exportAllUser(String activityId, String optName, String userId, HttpServletResponse response);

    List<UserQaInfo> getUserQas(String userId, String activityId);


    Double getTaskQuantityByUids(String activityId, String taskId, List<String> uids);


    ReceiveCaVO receiveCa(String activityId, String appId, UserPO userPO);

    ActivityFootPrintDomain getActivityFootPrint(String userId, String activityId, String taskBizType);

    Double getOrgQByOrgIds(String activityId, String taskId, List<String> organizerIds);

    /**
     * 补充报名信息，针对积分
     *
     * @param request
     * @param userPO
     */
    void extSignUpActivity(ActivitySignUpRequest request, UserPO userPO);

    /**
     * 生成证书
     *
     * @param activityId
     * @param activityName
     * @param userPO
     * @param platform
     */
    void generateUserCa(String activityId, String activityName, UserPO userPO, String platform);


    /**
     * 更新活动用户参与人数
     *
     * @param activityId
     * @param num
     * @param date
     */
    void updateActivityJoinNum(String activityId, Integer num, Date date);

    ActivityTaskDataDomain getTaskDataDomain(ActivityTaskInfo taskInfo, String userId, ActivityRewardRule
            rule, List<String> uid);

    /**
     * 获取活动用户贡献值
     *
     * @param activityId
     * @param type
     * @param taskId
     * @param uids
     * @return
     */
    Double getTaskQuantity(String activityId, String type, String taskId, List<String> uids);

    /**
     * 获取用户贡献值
     *
     * @param activityId
     * @param type
     * @param taskId
     * @param uids
     * @return
     */
    List<UserParticipateActivityInfo> getUserQuantity(String activityId, String type, String taskId, List<String> uids);


    Double computeQaScore(UserDoQaVO req);

    /**
     * 更新用户总榜单
     *
     * @param userPO
     * @param taskInfo
     * @param optType,0:累加,1:替换
     */
    void updateUserTaskAllRanking(final UserPO userPO, UserParticipateActivityTaskInfo taskInfo,
                                  final Integer optType);
}
